﻿using Acme.BookStore.AcmeModel;
using Acme.BookStore.Position;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Acme.BookStore
{
    /// <summary>
    /// 职位
    /// </summary>
    public class PositionServer :
        CrudAppService<
            PositionInfo, //The Book entity
            PositionInfoDto, //Used to show books
            Guid, //Primary key of the book entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            PositionInfos>, //Used to create/update a book
        IPositionInfo //implement the IBookAppService
    {
        public IRepository<PositionInfo, Guid> _Position;
        public IRepository<PdepatInfo, Guid> _Pdepa;
        public PositionServer(IRepository<PositionInfo, Guid> Position, IRepository<PdepatInfo, Guid> Pdepa)
            : base(Position)
        {
            _Position = Position;
            _Pdepa = Pdepa;
        }
        //显示
        public List<PositionInfos> GetShow()
        {
            var str = (from a in _Position
                       join b in _Pdepa
                       on a.PositionDepartment equals b.Id.ToString()
                       select new PositionInfos
                       {
                           PositionName = a.PositionName,
                           PositionAlias = a.PositionAlias,
                           PositionDepartment = a.PositionDepartment,
                           PositionTime = a.PositionTime,
                           DepartmentName = b.DepartmentName,
                       }).ToList();
            return str;
        }
    }
}
